__doc__ =   """ PropertyDict classes to annotate residues with tabularized data.
            """

from AbstractPropertyDict import AbstractResiduePropertyDict
from ResidueProperties import *
from Einput import einput

class AbstractResiduePropertyTabularized(AbstractResiduePropertyDict):
    """ Residue property from table.
    """
    def __init__(self, entities, property, xtra_key):
        residues = einput(entities, 'R', 'residues')
        prop_dict = {}

        for (id_, residue) in residues.iteritems():
            res_name = residue.get_name()
            result = property.get(res_name)
            if result is None:
                # 'X', '*', H_.... or any other
                continue
            prop_dict[id_] = result
            # Add to xtra
            residue.xtra[xtra_key] = result
        AbstractResiduePropertyDict.__init__(self, prop_dict)


class ResidueEntropy(AbstractResiduePropertyTabularized):
    """
    """
    def __init__(self, entities):
        xtra_key = 'RE'
        property = AA_ENTROPY
        AbstractResiduePropertyTabularized.__init__(self, entities, property, xtra_key)


class ResidueGravy(AbstractResiduePropertyTabularized):
    """
    """
    def __init__(self, entities):
        xtra_key = 'RG'
        property = AA_GRAVY
        AbstractResiduePropertyTabularized.__init__(self, entities, property, xtra_key)


class ResidueSolvatation(AbstractResiduePropertyTabularized):
    """
    """
    def __init__(self, entities):
        xtra_key = 'RS'
        property = AA_SOLVATATION
        AbstractResiduePropertyTabularized.__init__(self, entities, property, xtra_key)


class ResidueCharge(AbstractResiduePropertyTabularized):
    """
    """
    def __init__(self, entities):
        xtra_key = 'RC'
        property = AA_CHARGE
        AbstractResiduePropertyTabularized.__init__(self, entities, property, xtra_key)


class ResiduePolarity(AbstractResiduePropertyTabularized):
    """
    """
    def __init__(self, entities):
        xtra_key = 'RP'
        property = AA_POLARITY
        AbstractResiduePropertyTabularized.__init__(self, entities, property, xtra_key)


class ResidueAA_5(AbstractResiduePropertyTabularized):
    """
    """
    def __init__(self, entities):
        xtra_key = 'AA_5'
        property = AA_5
        AbstractResiduePropertyTabularized.__init__(self, entities, property, xtra_key)

class ResidueAA_2(AbstractResiduePropertyTabularized):
    """
    """
    def __init__(self, entities):
        xtra_key = 'AA_2'
        property = AA_2
        AbstractResiduePropertyTabularized.__init__(self, entities, property, xtra_key)

class ResidueAA_4MURPHY(AbstractResiduePropertyTabularized):
    """
    """
    def __init__(self, entities):
        xtra_key = 'AA_4MURPHY'
        property = AA_4MURPHY
        AbstractResiduePropertyTabularized.__init__(self, entities, property, xtra_key)

class ResidueAA_8MURPHY(AbstractResiduePropertyTabularized):
    """
    """
    def __init__(self, entities):
        xtra_key = 'AA_8MURPHY'
        property = AA_8MURPHY
        AbstractResiduePropertyTabularized.__init__(self, entities, property, xtra_key)

class ResidueAA_10MURPHY(AbstractResiduePropertyTabularized):
    """
    """
    def __init__(self, entities):
        xtra_key = 'AA_10MURPHY'
        property = AA_10MURPHY
        AbstractResiduePropertyTabularized.__init__(self, entities, property, xtra_key)

class ResidueAA_15MURPHY(AbstractResiduePropertyTabularized):
    """
    """
    def __init__(self, entities):
        xtra_key = 'AA_15MURPHY'
        property = AA_15MURPHY
        AbstractResiduePropertyTabularized.__init__(self, entities, property, xtra_key)

#EOF